package com.li.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.li.DTO.HostDTO;
import com.li.VO.PageListVO;
import com.li.mapper.HostMapper;
import com.li.pojo.Host;
import com.li.service.HostService;
import com.li.util.BeanContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: zhiqingLi
 * @Description:
 * @Date: Created in 20:47 2024/3/13
 **/
@Service
public class HostServiceImpl implements HostService {

    @Autowired
    private HostMapper hostMapper;

    @Override
    public PageListVO showList(HostDTO hostDTO) {
        PageHelper.startPage(hostDTO.getPageIndex(),hostDTO.getPageSize());
        Page<Host> page = hostMapper.showList(hostDTO.getName(), BeanContent.getCurrentId());
        return new PageListVO(page.getTotal(),page.getResult());
    }

    @Override
    public void addSubregion(Host host) {
        host.setCompanyId(BeanContent.getCurrentId());
        host.setIsf(0);
        hostMapper.addSubregion(host);
    }

    @Override
    public Host updGetById(Long id) {
        return hostMapper.updGetById(id);
    }

    @Override
    public void updSubregion(Host host) {
        hostMapper.updSubregion(host);
    }

    @Override
    public void delById(Long id) {
        hostMapper.delById(id);
    }

    @Override
    public List<Host> showNameByHostName(String name) {
        return hostMapper.showNameByHostName(name);
    }
}
